package com.csis.framework.util.jqgrid;

import java.util.ArrayList;
import java.util.List;

import com.csis.framework.domain.Condition;

/**
 * For jqGrid plug model in client
 * 
 * @author dailey_dai
 * 
 */
public class JqGridModel {
	// current page
	private String page;
	// pageSize
	private String rows;
	// order by
	private String sidx;
	// sort by desc or asc
	private String sord;

	private String _search;

	//like ware_id etc. use to cascade jqgrid
	private Integer id;

	private Integer monitorCount;

	/**
	 * @return the monitorCount
	 */
	public Integer getMonitorCount() {
		return monitorCount;
	}

	/**
	 * @param monitorCount the monitorCount to set
	 */
	public void setMonitorCount(Integer monitorCount) {
		this.monitorCount = monitorCount;
	}

	String searchField;
	/**
	 * 
	 */
	String searchOper;
	/**
	 * 
	 */
	String searchString;

	
	private Boolean isAll;

	/**
	 * @return the isAll
	 */
	public Boolean getIsAll() {
		return isAll;
	}

	/**
	 * @param isAll the isAll to set
	 */
	public void setIsAll(Boolean isAll) {
		this.isAll = isAll;
	}
	/**
	 * @return the id
	 */
	public Integer getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	public String getSearchField() {
		return searchField;
	}

	public void setSearchField(String searchField) {
		this.searchField = searchField;
	}

	public String getSearchOper() {
		return searchOper;
	}

	public void setSearchOper(String searchOper) {
		this.searchOper = searchOper;
	}

	public String getSearchString() {
		return searchString;
	}

	public void setSearchString(String searchString) {
		this.searchString = searchString;
	}

	/**
	 * @return the _search
	 */
	public String get_search() {
		return _search;
	}

	/**
	 * @param _search the _search to set
	 */
	public void set_search(String _search) {
		this._search = _search;
	}

	private List<JqGridSearchOperation> searchOperations = new ArrayList<JqGridSearchOperation>();

	private Condition searchCondition;

	public JqGridModel() {
	}

	/**
	 * @return the searchCondition
	 */
	public Condition getSearchCondition() {
		return searchCondition;
	}

	/**
	 * @param searchCondition the searchCondition to set
	 */
	public void setSearchCondition(Condition searchCondition) {
		this.searchCondition = searchCondition;
	}

	public boolean isSearch() {
		if (searchOper == null || searchOper.trim().length() == 0) {
			return false;
		}
		searchCondition = new JqGridSearchOperation(this);
		return true;
	}

	/**
	 * @return the searchOperations
	 */
	public List<JqGridSearchOperation> getSearchOperations() {
		return searchOperations;
	}

	/**
	 * @param searchOperations the searchOperations to set
	 */
	public void setSearchOperations(List<JqGridSearchOperation> searchOperations) {
		this.searchOperations = searchOperations;
	}

	public String getPage() {
		return page;
	}

	public void setPage(String page) {
		this.page = page;
	}

	public String getRows() {
		return rows;
	}

	public void setRows(String rows) {
		this.rows = rows;
	}

	public String getSidx() {
		return sidx;
	}

	public void setSidx(String sidx) {
		this.sidx = sidx;
	}

	public String getSord() {
		return sord;
	}

	public void setSord(String sord) {
		this.sord = sord;
	}

	@Override
	public String toString() {
		return "JqGridModel [page=" + page + ", rows=" + rows + ", sidx=" + sidx + ", sord=" + sord + "]";
	}

}
